import unittest
from venv1.Public import HTMLTestReportCNPy3
# from Public import HTMLTestReportCNPy3
import os
import time
from venv1.TestCase.OWB_Case import OWB_Case
from venv1.TestCase.Login_Case import Login_Case
from venv1.TestCase.Inquery_Case import Inquery_Case
from venv1.TestCase.UW_Case import UW_Case
from venv1.TestCase.PolicyIfmCom_Case import PolicyIfmCom_Case
dir=os.path.abspath(os.curdir)
result = dir+"\\Result\\"








#创建测试集
def CreateSuite():
    suite = unittest.TestSuite()
    case1 =unittest.TestLoader().loadTestsFromTestCase(OWB_Case)
    suite.addTest(case1)
    return suite

#生成报告
def run():
    suite = CreateSuite()
    day = time.strftime('%Y-%m-%d',time.localtime(time.time()))
    rep_dir= result+day
    if not os.path.exists(rep_dir):
        os.makedirs(rep_dir)
    filename=rep_dir+'\\'+"result.html"
    f = open(filename,'wb')
    runner=HTMLTestReportCNPy3.HTMLTestRunner(stream=f,title='测试报告',description='第一次运行测试报告')
    runner.run(suite)
    f.close()

if __name__ == '__main__':
    run()